<?php
function doctor_anons(){
    ob_start();
    $doc=  mysql_fetch_assoc(mysql_query('select * from vrach where weight>0 order by RAND() limit 0,1'));
?>
                        <div class="person">
                        <a href="/doctors/<?=$doc['name']?>.html">
                            <img src="/images/vrachi/<?=$doc['id']?>---200.jpg" alt="<?=$doc['title']?>" />
                            <div>
                                <b><?=$doc['title']?></b><br/><?=$doc['regals']?>
                            <br/></div>
                        </a><hr />
                        <a href="#" id="quest_open" style="text-align: center; display: block;"><img src="/images/vopros.png" align="center" /></a>
                        <?
                            include_once '7ert54/quest.php';                            
                        ?>
                        </div><br/>
<?
    
    return ob_get_clean();
}
function doc_list($type){
    if ($type=='title'){
        return 'Врачи';
    }
    if ($type=='content'){
        ob_start();
        $d=mysql_query('select * from vrach order by weight desc');    
        echo '<div class="doc_list">';
        while ($doc=  mysql_fetch_assoc($d)){
            if (file_exists(LocalDir.'/images/vrachi/'.$doc['id'].'---100.jpg'))
                $img='<img src="/images/vrachi/'.$doc['id'].'---100.jpg" />';
            else
                $img='<img src="/images/no-logo.jpg" width="110" />';
            ?>
            <div class="doc_list_item">
                <table>
                    <tr>
                        <td>
                            <a href="/doctors/<?=$doc['name']?>.html">
                            <?=$img?>
                            </a>
                        </td>
                        <td>
                            <a href="/doctors/<?=$doc['name']?>.html">
                            <h2><?=$doc['title']?></h2></a>
                            
                            <?=$doc['short']?>
                            
                        </td>
                    </tr>
                </table>
            </div>
            <?
        }    
        echo '</div>';
        return ob_get_clean();
    }
}
function DocInfo($type, $doc_name){
    $doc_name=  mysql_real_escape_string($doc_name);
    $qr=mysql_query('select * from vrach where name="'.$doc_name.'" limit 0,1') or die(mysql_error());
    $doc=  mysql_fetch_assoc($qr);
    
    if ($type=='title'){
        return $doc['title'];
    }
    if ($type=='content'){
        if ($_SESSION['level'] >= 5)
           echo '<div><div ondblclick="parent.location=\'/ADM/edit/' . $doc['id'] . '/?vid=vrach\'" title="Кликните дважды для редактирования">
<a href="/ADM/delete/'.$doc['id'].'/?vid=vrach">Удалить</a>
';
        if ($_SESSION['level'] >= 5)
            echo '<a href="/ADM/edit/' . $doc['id'] . '/?vid=vrach" style="color: red">Редактировать</a><br /></div>';

        if (file_exists(LocalDir.'/images/vrachi/'.$doc['id'].'---200.jpg'))
            $img='<img src="/images/vrachi/'.$doc['id'].'---200.jpg" style="float:left; padding-right:10px;"/>';
        else
            $img='<img src="/images/no-logo.jpg" width="110" style="float:left; padding-right:10px;"/>';
        ob_start();
        ?>
        <?=$img?>
        <b><?=$doc['short']?></b>
        <p><?=$doc['content']?></p>
        <?
        return ob_get_clean();
    }
    
}
function doctors($type, $path){
    if (empty($path[2])){
        return doc_list($type);
    }else{
        return DocInfo($type,$path[2]);
    }
}
?>
